<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>订单信息</title>
	<script type="text/javascript">
		var menu_flag = 'order';
		$(function(){
			$("input[id$=Date]").attr("readonly",true);
			$("input[id$=Date]").datepicker({changeYear:true,changeMonth:true});
			//$("input[id$=Date]").datepicker.formatDate('yyyy-mm-dd',new Date());
		});
	</script>
	<script language="javascript" type="text/javascript" src="${ctx}/static/js/jquery.coolfieldset.js"></script>
	<link rel="stylesheet" type="text/css" href="${ctx}/static/css/jquery.coolfieldset.css" />
</head>
<body>
	
	<div class="sitemap" id="sitemap">
		当前位置: <a href="list">订单</a> -&gt; 修改订单-&gt;&gt;
		 <span class="red">订单号： ${obj.orderCode}</span>  操作人：${obj.operator.name}
	</div>
	
	
		<div id="secmainoutside">
			<form id="editForm" action="" method="post">
				<fieldset id="base_info" class="coolfieldset">
				<legend>基本信息</legend>
				<div style="padding:2px">
				
				<table class="mainadd">
					<tbody>
					<input type="hidden" class="text" id="id" name="id" value="${obj.id}"/>
					<input type="hidden" class="text" id="orderCode" name="orderCode" value="${obj.orderCode}"/>
						<tr>
							<td class="name">MBL号</td>
							<td class="content">
								<input type="text" class="text" id="mblCode" name="mblCode" value="${obj.mblCode}" maxlength='100'/>
								<span class="red">*</span>
							</td>
						
							<td class="name">SO单号</td>
							<td class="content">
								<input type="text" class="text" id="so" name="so" value="${obj.so}" maxlength='50'/>
							</td>
						</tr>
						<tr>
						<td> 整装类型</td>
							<td class="content">
								<c:choose>
									<c:when test="${obj.containerType=='0'}">
										<input type="radio" name="containerType" id="containerType" value="0" checked="checked"/>FCL
										<input type="radio" name="containerType" id="containerType" value="1"/>LCL
									</c:when>
									<c:when test="${obj.containerType=='1'}">
										<input type="radio" name="containerType" id="containerType" value="0" />FCL
										<input type="radio" name="containerType" id="containerType" value="1" checked="checked"/>LCL
									</c:when>
									<c:otherwise>
										<input type="radio" name="containerType" id="containerType" value="0"/>FCL
										<input type="radio" name="containerType" id="containerType" value="1"/>LCL
									</c:otherwise>
								</c:choose>
								
							</td>
							
						 <td> 客户</td>
							<td class="content">
								<input type="text" class="text" id="customerAuto" name="customerAuto" value="${obj.customer.name}" maxlength='50'/>
								<input type="hidden" class="text" id="customer" name="customer.id"  value="${obj.customer.id}" maxlength='50'/>
							</td>
							
							<td>详细</td>
							<td >
								<textarea rows="6" cols="40" id="customerDetail" name="customerDetail">${obj.customerDetail}</textarea>
							</td>
						</tr>
						<tr>
						<td>揽货</td>
							<td class="content">
							<c:choose>
									<c:when test="${obj.cargoCollectionType=='0'}">
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="1" />指定
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="0" checked="checked"/>自揽
									</c:when>
									<c:when test="${obj.cargoCollectionType=='1'}">
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="1" checked="checked"/>指定
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="0" />自揽
									</c:when>
									<c:otherwise>
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="1" />指定
										<input type="radio" name="cargoCollectionType" id="cargoCollectionType" value="0"/>自揽
									</c:otherwise>
								</c:choose>
								
							</td>
							
						 <td> 指定代理</td>
							<td class="content">
								<input type="text" class="text" id="cargoCollectionAuto" name="cargoCollectionAuto" value="${obj.cargoCollection.name}" maxlength='50'/>
								<input type="hidden" class="text" id="cargoCollection" name="cargoCollection.id" value="${obj.cargoCollection.id}" maxlength='50'/>
							</td>
							
							<td>详细</td>
							<td >
								<textarea rows="6" cols="40" id="cargoCollectionDetail" name="cargoCollectionDetail">${obj.cargoCollectionDetail}</textarea>
							</td>
						</tr>
						
						<tr>
							<td class="name">发货人</td>
							<td class="content">
								<input type="text" class="text" id="shipperAuto" name="shipperAuto" value="${obj.shipper.name}" maxlength='100'/>
								<input type="hidden" class="text" id="shipper" name="shipper.id" value="${obj.shipper.id}" maxlength='100'/>
							</td>
						
					
							<td class="name">收货人</td>
							<td class="content">
								<input type="text" class="text" id="consigneeAuto" name="consigneeAuto" maxlength='100'/>
								<input type="hidden" class="text" id="consignee" name="consignee.id" value="" maxlength='100'/>
							</td>
							
							<td class="name">通知人</td>
							<td class="content">
								<input type="text" class="text" id="notifierId" name="notifierId" maxlength='100'/>
							</td>
						</tr>
						<tr>
							<td>发货人详细</td>
							<td >
								<textarea rows="6" cols="40" id="shipperDetail" name="shipperDetail">${obj.shipperDetail}</textarea>
							</td>
							<td>收货人详细</td>
							<td >
								<textarea rows="6" cols="40" id="consigneeDetail" name="consigneeDetail">${obj.consigneeDetail}</textarea>
							</td>
							<td>通知人详细</td>
							<td >
								<textarea rows="6" cols="40" id="notifierDetail" name="notifierDetail">${obj.notifierDetail}</textarea>
							</td>
						</tr>
					</tbody>
			</table>
			</div>
			</fieldset>
			
			
			<fieldset id="base_info" class="coolfieldset">
				<legend>港口信息</legend>
				<div style="padding:2px">
				<table class="mainadd">
					<tbody>
						<tr>
							<td class="name">收货地</td>
							<td class="content">
								<input type="text" class="text" id="receiptPlacePauto" name="receiptPlacePauto" value="${obj.receiptPlace.name}" maxlength='100'/>
								<input type="hidden" class="text" id="receiptPlace" name="receiptPlace.id" value="${obj.receiptPlace.id}" maxlength='100'/>
							</td>
						<td class="name">目的地</td>
							<td class="content">
								<input type="text" class="text" id="destinationPlacePauto" name="destinationPlacePauto" value="${obj.destinationPlace.name}" maxlength='100'/>
								<input type="hidden" class="text" id="destinationPlace" name="destinationPlace.id" value="${obj.destinationPlace.id}" maxlength='100'/>
							</td>
						</tr>
						
						<tr>
							<td class="name">起运港</td>
							<td class="content">
								<input type="text" class="text" id="loadingPortPauto" name="loadingPortPauto" value="${obj.loadingPort.name}" maxlength='100'/>
								<input type="hidden" class="text" id="loadingPort" name="loadingPort.id" value="${obj.loadingPort.id}" maxlength='100'/>
							</td>
							<td class="name">卸运港</td>
							<td class="content">
								<input type="text" class="text" id="unloadingPortPauto" name="unloadingPortPauto" value="${obj.unloadingPort.name}" maxlength='100'/>
								<input type="hidden" class="text" id="unloadingPort" name="unloadingPort.id" value="${obj.unloadingPort.id}"  maxlength='100'/>
							</td>
								<td class="name">目的港</td>
							<td class="content">
								<input type="text" class="text" id="destinationPortPauto" name="destinationPortPauto" value="${obj.destinationPort.name}" maxlength='100'/>
								<input type="hidden" class="text" id="destinationPort" name="destinationPort.id" value="${obj.destinationPort.id}" maxlength='100'/>
							</td>
						</tr>
						
						<tr>
						<td class="name">集装箱</td>
							<td class="content">
								<input type="text" class="text" id="containerInfo" name="containerInfo" value="${obj.containerInfo}" maxlength='100'/>
							</td>
						</tr>
					</tbody>
			</table>
			</div>
			</fieldset>
			
			<fieldset id="base_info" class="coolfieldset">
				<legend>货物信息</legend>
				<div style="padding:2px">
				<table class="mainadd">
					<tbody>
						<tr>
							<td class="name">大包类型*数目</td>
							<td class="content">
								<input type="text" id="largePackingType.id" name="largePackingType.id" maxlength='100'/>*
								<input type="text" size="3" id="largeNumber " name="largeNumber" value="${obj.largeNumber}"/>
							</td>
						
					
							<td class="name">小包类型*数目</td>
							<td >
								<input type="text" id="smallPackingType.id" name="smallPackingType.id" maxlength='50'/>*
								<input type="text" size="3" id="smallNumber" name="smallNumber" value="${obj.smallNumber}"/>
							</td>

						</tr>
						
						<tr>
							<td class="name">毛重</td>
							<td class="content">
								<input type="text" class="text" id="grossWeight" name="grossWeight" value="${obj.grossWeight}"  maxlength='50'/>
							</td>
					
							<td class="name">体积</td>
							<td class="content">
								<input type="text" class="text" id="volume" name="volume" value="${obj.volume}"  maxlength='50'/>
							</td>
						</tr>
						
						<tr>
							<td >中文品名</td>
							<td >
								<textarea rows="6" cols="40" id="chineseName" name="chineseName">${obj.chineseName}</textarea>
							</td>
					
							<td>英文品名</td>
							<td>
								<textarea rows="6" cols="40" id="englishName" name="englishName">${obj.englishName}</textarea>
							</td>
							
						
						</tr>
						<tr>
						
							<td>唛头</td>
							<td >
								<textarea rows="6" cols="40" id="shippingMark" name="shippingMark">${obj.shippingMark}</textarea>
							</td>
							
							<td>总计</td>
							<td >
								<textarea rows="6" cols="40" id="infoSummy" name="infoSummy">${obj.infoSummy}</textarea>
							</td>
						</tr>
					</tbody>
			</table>
			</div>
			</fieldset>
			
			<fieldset id="base_info" class="coolfieldset">
				<legend>订舱信息</legend>
				<div style="padding:2px">
				<table class="mainadd">
					<tbody>
					<tr>
						 <td class="name">船名/航次</td>
							<td class="content">
								<input type="text" class="text" id="shippingNameNumber" name="shippingNameNumber" value="${obj.shippingNameNumber}" maxlength='50'/>
							</td>
								
							<td class="name">状态</td>
							<td class="content">
								<input type="text" class="text" id="status" name="status" value="${obj.status}" maxlength='50'/>
							</td>
							<td class="name">封箱号</td>
							<td class="content">
								<input type="text" class="text" id="sealingNumber" name="sealingNumber" value="${obj.sealingNumber}" maxlength='50'/>
							</td>
						</tr>
						<tr>
							<td class="name">订舱日</td>
							<td class="content">
								<input type="text" class="text" id="bookingDate" name="bookingDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${obj.bookingDate}"/>" maxlength='100'/>
							</td>
							
							<td class="name">开船日</td>
							<td class="content">
								<input type="text" class="text" id="shippingDate" name="shippingDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${obj.shippingDate}"/>" maxlength='50'/>
							</td>
							
							<td class="name">到港日</td>
							<td class="content">
								<input type="text" class="text" id="arrivalDate" name="arrivalDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${obj.arrivalDate}"/>" maxlength='50'/>
							</td>
						</tr>
						
						<tr>
						
							<td class="name">签发地</td>
							<td class="content">
								<input type="text" class="text" id="issueAddress" name="issueAddress" value="${obj.issueAddress}"  maxlength='50'/>
							</td>
							
							<td class="name">签发数</td>
							<td class="content">
								<input type="text" class="text" id="issueNumber" name="issueNumber" value="${obj.issueNumber}"  maxlength='50'/>
							</td>
							
								<td class="name">签发日</td>
							<td class="content">
								<input type="text" class="text" id="issueDate" name="issueDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${obj.issueDate}"/>" maxlength='50'/>
							</td>
						</tr>
					
						<tr>
						 <td class="name">M付款方式</td>
							<td class="content">
							<c:choose>
									<c:when test="${obj.mPaymentType=='1'}">
										<input type="radio" name="mPaymentType" id="mPaymentType" value="1" checked="checked"/>FREIGHT PREPAID
										<input type="radio" name="mPaymentType" id="mPaymentType" value="2"/>FREIGHT COLLECT
									</c:when>
									<c:when test="${obj.mPaymentType=='2'}">
										<input type="radio" name="mPaymentType" id="mPaymentType" value="1"/>FREIGHT PREPAID
										<input type="radio" name="mPaymentType" id="mPaymentType" value="2" checked="checked"/>FREIGHT COLLECT
									</c:when>
									<c:otherwise>
										<input type="radio" name="mPaymentType" id="mPaymentType" value="1"/>FREIGHT PREPAID
										<input type="radio" name="mPaymentType" id="mPaymentType" value="2"/>FREIGHT COLLECT
									</c:otherwise>
								</c:choose>
							
							</td>
							
							<td class="name">H付款方式</td>
							<td class="content">
								<c:choose>
									<c:when test="${obj.hPaymentType=='1'}">
										<input type="radio" name="hPaymentType" id="hPaymentType" value="1" checked="checked"/>FREIGHT PREPAID
										<input type="radio" name="hPaymentType" id="hPaymentType" value="2"/>FREIGHT COLLECT
									</c:when>
									<c:when test="${obj.hPaymentType=='2'}">
										<input type="radio" name="hPaymentType" id="hPaymentType" value="1"/>FREIGHT PREPAID
										<input type="radio" name="hPaymentType" id="hPaymentType" value="2" checked="checked"/>FREIGHT COLLECT
									</c:when>
									<c:otherwise>
										<input type="radio" name="hPaymentType" id="hPaymentType" value="1"/>FREIGHT PREPAID
										<input type="radio" name="hPaymentType" id="hPaymentType" value="2"/>FREIGHT COLLECT
									</c:otherwise>
								</c:choose>
							</td>
						</tr>
						
						<tr>
						 <td class="name">M放货方式</td>
							<td class="content">
							<c:choose>
									<c:when test="${obj.mReleaseWay=='1'}">
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="1" checked="checked"/>电放
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="2"/>正本提单
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="3"/>SWB
									</c:when>
									<c:when test="${obj.mReleaseWay=='2'}">
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="1" />电放
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="2" checked="checked"/>正本提单
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="3"/>SWB
									</c:when>
									<c:when test="${obj.mReleaseWay=='3'}">
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="1"/>电放
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="2"/>正本提单
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="3" checked="checked"/>SWB
									</c:when>
									<c:otherwise>
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="1"/>电放
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="2"/>正本提单
										<input type="radio" name="mReleaseWay" id="mReleaseWay" value="3"/>SWB
									</c:otherwise>
								</c:choose>
								
							</td>
							
							<td class="name">H付款方式</td>
							<td class="content">
							<c:choose>
									<c:when test="${obj.mReleaseWay=='1'}">
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="1" checked="checked"/>电放
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="2"/>正本提单
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="3"/>SWB
									</c:when>
									<c:when test="${obj.mReleaseWay=='2'}">
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="1" />电放
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="2" checked="checked"/>正本提单
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="3"/>SWB
									</c:when>
									<c:when test="${obj.mReleaseWay=='3'}">
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="1"/>电放
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="2"/>正本提单
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="3" checked="checked"/>SWB
									</c:when>
									<c:otherwise>
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="1"/>电放
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="2"/>正本提单
										<input type="radio" name="hReleaseWay" id="hReleaseWay" value="3"/>SWB
									</c:otherwise>
								</c:choose>
							</td>
						</tr>
							<tr>
						 <td>船公司</td>
							<td class="content">
								<input type="text" class="text" id="shippingCompany.id" name="shippingCompany.id" maxlength='50'/>
							</td>
							
							<td>详细</td>
							<td >
								<textarea rows="6" cols="40" id="shippingCompanyDetail" name="shippingCompanyDetail">${obj.shippingCompanyDetail}</textarea>
							</td>
						</tr>
						
						<tr>
						 <td>订舱代理</td>
							<td class="content">
								<input type="text" class="text" id="bookingProxyCompany.id" name="bookingProxyCompany.id" maxlength='50'/>
							</td>
							
							<td>详细</td>
							<td >
								<textarea rows="6" cols="40" id="bookingProxyCompanyDetail" name="bookingProxyCompanyDetail">${obj.bookingProxyCompanyDetail}</textarea>
							</td>
						</tr>
						
							<tr>
							<td>运输条款</td>
							<td >
								<textarea rows="6" cols="40" id="transitClause" name="transitClause">${obj.transitClause}</textarea>
							</td>
							
							<td>费用说明</td>
							<td >
								<textarea rows="6" cols="40" id="feeDescription" name="feeDescription">${obj.feeDescription}</textarea>
							</td>
							<td>备注</td>
							<td >
								<textarea rows="6" cols="40" id="remark" name="remark">${obj.remark}</textarea>
							</td>
							
						</tr>
					</tbody>
			</table>
			</div>
			</fieldset>
			<table>
					<tfoot>
						<tr>
							<td class="name"></td>
							<td class="btn">
								<input type="submit" class="bigbutsubmit" value="提交"  id="butsubmit_id"/>
								<input type="button" class="bigbutsubmit" onclick="javascript:window.location.href='list';" value="返回"/>
							</td>
						</tr>
					</tfoot>
				</table>
			</form>
		</div>
	<script type="text/javascript">
	//$(document).ready(function(){
		//		var options = "";
			//	$.each(company_type,function(index, context) {
				//	options += "<option value="+context.code+">"+context.name+"</option>";
			//	});
				//$("#type").html(options);
			//});
		var companys;
	
				$.ajax({
					url: "../company/ajaxData",
					dataType: "json",
					async : false,
					success: function(data) {
					//function(request,response){
						//response($.map(companys,function(company){
						//	return {label:company.value,value:company.name};
						//}));
					//},
			
						companys = $.map(data,function(company){
							return {label:company.name,value:company.name,icon:company.id,desc:company.type};
						});
					}
				});
			
	var ports;
		$.ajax({
					url: "../port/ajaxData",
					dataType: "json",
					async : false,
					success: function(data) {
					//function(request,response){
						//response($.map(companys,function(company){
						//	return {label:company.value,value:company.name};
						//}));
					//},
			
						ports = $.map(data,function(port){
							return {label:port.name,value:port.name,icon:port.id,desc:port.abbreviate};
						});
					}
				});
	$(function() {
		var projects = [
			{
				value: "jquery",
				label: "jQuery",
				desc: "the write less, do more, JavaScript library",
				icon: "1"
			},
			{
				value: "jquery-ui",
				label: "jQuery UI",
				desc: "the official user interface library for jQuery",
				icon: "2"
			},
			{
				value: "sizzlejs",
				label: "Sizzle JS",
				desc: "a pure-JavaScript CSS selector engine",
				icon: "3"
			}
		];
		
	$("input[id$=Auto]").click(function(){
			$(this).autocomplete("search", "");
			});
			//鼠标离开输入框操作
	//$("input[id$=Auto]").focusout(function(){
	//		var checkId = $(this).attr('id');
	//		alert("blur:"+checkId);
		//	});
	
	$("input[id$=Auto]").autocomplete({
			minLength: 0,
			source: companys,
			select: function(event, ui ) {
				var checkId = $(this).attr('id');
				var checkValue = checkId.slice(0,checkId.length-4);
				$("#"+checkValue+"Auto").val(ui.item.label);
				$("#"+checkValue).val(ui.item.icon);
				$("#"+checkValue+"Detail").val(ui.item.label);
				return false;
			},
			close: function() {
				var checkId = $(this).attr('id');
				var checkValue = checkId.slice(0,checkId.length-4);
				if($("#"+checkValue).val()==""){
					$("#"+checkValue+"Auto").val("");
				};
			}
		})
		//.data("autocomplete")._renderItem = function( ul, item ) {
		//	return $( "<li></li>" )
		//		.data( "item.autocomplete", item )
		//		.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
		//		.appendTo( ul );
		//};
		
		
		//港口
		
		$("input[id$=Pauto]").click(function(){
			$(this).autocomplete("search", "");
			});
			
		$("input[id$=Pauto]").autocomplete({
			delay: 0,
			minLength: 0,
			source:ports,
			select: function(event, ui ) {
				var checkId = $(this).attr('id');
				var checkValue = checkId.slice(0,checkId.length-5);
				$("#"+checkValue).val(ui.item.icon);
				$("#"+checkValue+"Pauto").val(ui.item.label);
				return false;
			},
			close: function() {
				var checkId = $(this).attr('id');
				var checkValue = checkId.slice(0,checkId.length-5);
				if($("#"+checkValue).val()==""){
					$("#"+checkValue+"Pauto").val("");
				};
			}
		})
		//.data("autocomplete")._renderItem = function( ul, item ) {
		//	return $( "<li></li>" )
		//		.data( "item.autocomplete", item )
		//		.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
		//		.appendTo( ul );
		//};
	});
		
	$(document).ready(function(){
		$("#editForm").validate({
			rules: {
				
			},
			messages: {
				
			},
			errorPlacement: function(error, element){
			
			},
			submitHandler: function(form) {
				$("#butsubmit_id").attr("disabled","true");
				setDisabled('input[type="submit"]', window.document)
				$(form).ajaxSubmit({
					 success: function(response){
		        		var data = eval("("+response+")");
		        		if(data.flag==0){
	            			$.alert('修改订单成功', function(){window.location.href = "list";});
	            		}else{
	                		$.alert('修改失败,请重新输入');
	                		$("#butsubmit_id").attr("disabled","false");
	            		}
		        		setabled('input[type="submit"]', window.document);
		            }
	            });
			},
			success: function(label){
				var labelparent = label.parent();
				label.parent().html(labelparent.next().html()).attr("class", "valid");
			},
			onkeyup:false
		});
			
	});
	</script>
</body>
</html>